#ifndef VIEW_H
#define VIEW_H

#include <vector>
#include "rect.h"
class Font;

class View {
public:
     View(Rect r=Rect(), Font *pFont=NULL);
     Font* font();
     void setFont(Font *pFont);
     virtual bool needPaint();
     virtual Rect rect() const;
     virtual void setRect(Rect r);
     virtual void keyDown(int keycode, int modifiers, int unichar);
     virtual void mouseDown(Point p, int button);
     virtual void mouseUp(Point p, int button);
     virtual void mouseMove(Point p, Point dp);
     virtual void mouseEnter(Point p);
     virtual void mouseExit(Point p);
     virtual bool grabMouse();
     // pass all=true to force repaint of view and all children
     virtual void paint(bool all=false);
     virtual void update();
     void refresh();
     void show();
     void hide();
     bool visible();
     void clear();
     virtual bool grabKeys();
     virtual bool hasFocus();
     virtual void focus();
     virtual void blur();

protected:
     bool m_needPaint;
     bool m_grabMouse;
     bool m_visible;
     Rect m_rect;
     Font *m_pFont;
     std::vector<View*> m_views;
     Point m_oldMousePos;
     bool m_needFlip;
     bool m_grabKeys;
     bool m_hasFocus;
};

#endif
